home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10412 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: dawn.mmm.com!news
  2. From: kjhopps@mmm.com (Kevin J Hopps)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Default values for constructor arguments
  5. Date: 7 Mar 1996 19:08:03 GMT
  6. Organization: 3M - St. Paul, MN  55144-1000 US
  7. Message-ID: <4hnc6j$mgj@dawn.mmm.com>
  8. References: <4hjoof$5qk@newnews.iafrica.com>
  9. Reply-To: kjhopps@mmm.com
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. Peter Golda (goldap@telkom11.telkom.co.za) wrote:
  13. > Hi,
  14.  
  15. > I had a constructor for my MWMessageLog class as follows:
  16.  
  17. >     MWMessageLog(
  18. >         const RWCString& anExecutableCode,
  19. >         const RWCString& aSystemCode,
  20. >         const RWCString& aLogFilePath );
  21.  
  22. > where the class RWCString comes from the Rogue Wave development library
  23. > and is just a simple string class.
  24.  
  25. > Now, I wanted to add default values, so I wrote as follows (knowing that
  26. > RWCString has a constructor that constructs RWCString from char* and it
  27. > has an assignment operator):
  28.  
  29. >    MWMessageLog(
  30. >        ...
  31. >        ...
  32. >        const RWCString& aLogFilePath = "~/logs/" );
  33.  
  34. > but now the compiler moans that it doesn't like that since the default
  35. > value must be passed through a constructor. 
  36.  
  37. It works with SunSoft C++ 4.1.  You might try
  38.     MWMessageLog(
  39.     ...
  40.     const RWCString& aLogFilePath = RWCString("~/logs/"));
  41. --
  42. Kevin J. Hopps                  e-mail: kjhopps@mmm.com
  43. 3M Company                      phone:  (612) 737-4643
  44. 3M Center, Bldg. 235-2D-57      fax:    (612) 737-2700
  45. St. Paul, MN 55144-1000         Opinions are my own.  I don't speak for 3M.
  46.     But 3M speaks for me -- I did not write the following line:
  47.  
  48. Opinions expressed herein are my own and may not represent those of 3M.
  49.